package com.esri.core.tasks.geocode;

import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.tasks.e;
import com.esri.core.io.UserCredentials;
import com.esri.core.map.CallbackListener;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;

/* loaded from: classes.dex */
public abstract class Locator {
    private static final int TOLERANCE = 100;

    public abstract BatchGeocodeResult batchGeocode(List<Map<String, String>> list, SpatialReference spatialReference) throws Exception;

    public void dispose() {
    }

    public abstract List<LocatorGeocodeResult> find(LocatorFindParameters locatorFindParameters) throws Exception;

    public abstract List<LocatorGeocodeResult> find(LocatorSuggestionResult locatorSuggestionResult, int i, List<String> list, SpatialReference spatialReference) throws Exception;

    public abstract List<LocatorGeocodeResult> geocode(LocatorGeocodeParameters locatorGeocodeParameters) throws Exception;

    public abstract List<LocatorGeocodeResult> geocode(Map<String, String> map, List<String> list) throws Exception;

    public abstract List<LocatorGeocodeResult> geocode(Map<String, String> map, List<String> list, SpatialReference spatialReference) throws Exception;

    public abstract LocatorServiceInfo getInfo() throws Exception;

    public abstract String getUrl();

    public abstract LocatorReverseGeocodeResult reverseGeocode(Point point, double d) throws Exception;

    public abstract LocatorReverseGeocodeResult reverseGeocode(Point point, double d, SpatialReference spatialReference, SpatialReference spatialReference2) throws Exception;

    public abstract List<LocatorSuggestionResult> suggest(LocatorSuggestionParameters locatorSuggestionParameters) throws Exception;

    public static Locator createOnlineLocator() {
        return new OnlineLocator();
    }

    public static Locator createOnlineLocator(String str) {
        return new OnlineLocator(str);
    }

    public static Locator createOnlineLocator(String str, UserCredentials userCredentials) {
        return new OnlineLocator(str, userCredentials);
    }

    public static Locator createLocalLocator(String str) {
        return new LocalLocator(str);
    }

    public static Locator createLocalLocator(String str, LocatorSettings locatorSettings) {
        return new LocalLocator(str, locatorSettings);
    }

    public Future<List<LocatorGeocodeResult>> geocode(final Map<String, String> map, final List<String> list, final CallbackListener<List<LocatorGeocodeResult>> callbackListener) {
        return e.c.submit(new Callable<List<LocatorGeocodeResult>>() { // from class: com.esri.core.tasks.geocode.Locator.1
            @Override // java.util.concurrent.Callable
            public List<LocatorGeocodeResult> call() {
                List<LocatorGeocodeResult> list2 = null;
                try {
                    list2 = Locator.this.geocode(map, list);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return list2;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(list2);
                }
                return list2;
            }
        });
    }

    public Future<List<LocatorGeocodeResult>> geocode(final Map<String, String> map, final List<String> list, final SpatialReference spatialReference, final CallbackListener<List<LocatorGeocodeResult>> callbackListener) {
        return e.c.submit(new Callable<List<LocatorGeocodeResult>>() { // from class: com.esri.core.tasks.geocode.Locator.2
            @Override // java.util.concurrent.Callable
            public List<LocatorGeocodeResult> call() {
                List<LocatorGeocodeResult> list2 = null;
                try {
                    list2 = Locator.this.geocode(map, list, spatialReference);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return list2;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(list2);
                }
                return list2;
            }
        });
    }

    public Future<List<LocatorGeocodeResult>> geocode(final LocatorGeocodeParameters locatorGeocodeParameters, final CallbackListener<List<LocatorGeocodeResult>> callbackListener) {
        return e.c.submit(new Callable<List<LocatorGeocodeResult>>() { // from class: com.esri.core.tasks.geocode.Locator.3
            @Override // java.util.concurrent.Callable
            public List<LocatorGeocodeResult> call() {
                List<LocatorGeocodeResult> list = null;
                try {
                    list = Locator.this.geocode(locatorGeocodeParameters);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                        callbackListener.onCallback(list);
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return list;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(list);
                }
                return list;
            }
        });
    }

    public Future<List<LocatorGeocodeResult>> find(final LocatorFindParameters locatorFindParameters, final CallbackListener<List<LocatorGeocodeResult>> callbackListener) {
        return e.c.submit(new Callable<List<LocatorGeocodeResult>>() { // from class: com.esri.core.tasks.geocode.Locator.4
            @Override // java.util.concurrent.Callable
            public List<LocatorGeocodeResult> call() {
                List<LocatorGeocodeResult> list = null;
                try {
                    list = Locator.this.find(locatorFindParameters);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return list;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(list);
                }
                return list;
            }
        });
    }

    public Future<LocatorReverseGeocodeResult> reverseGeocode(final Point point, final double d, final CallbackListener<LocatorReverseGeocodeResult> callbackListener) {
        return e.c.submit(new Callable<LocatorReverseGeocodeResult>() { // from class: com.esri.core.tasks.geocode.Locator.5
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            public LocatorReverseGeocodeResult call() {
                LocatorReverseGeocodeResult locatorReverseGeocodeResult = null;
                try {
                    locatorReverseGeocodeResult = Locator.this.reverseGeocode(point, d);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return locatorReverseGeocodeResult;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(locatorReverseGeocodeResult);
                }
                return locatorReverseGeocodeResult;
            }
        });
    }

    public Future<LocatorReverseGeocodeResult> reverseGeocode(final Point point, final double d, final SpatialReference spatialReference, final SpatialReference spatialReference2, final CallbackListener<LocatorReverseGeocodeResult> callbackListener) {
        return e.c.submit(new Callable<LocatorReverseGeocodeResult>() { // from class: com.esri.core.tasks.geocode.Locator.6
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            public LocatorReverseGeocodeResult call() {
                LocatorReverseGeocodeResult locatorReverseGeocodeResult = null;
                try {
                    locatorReverseGeocodeResult = Locator.this.reverseGeocode(point, d, spatialReference, spatialReference2);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return locatorReverseGeocodeResult;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(locatorReverseGeocodeResult);
                }
                return locatorReverseGeocodeResult;
            }
        });
    }

    public Future<BatchGeocodeResult> batchGeocode(final List<Map<String, String>> list, final SpatialReference spatialReference, final CallbackListener<BatchGeocodeResult> callbackListener) {
        return e.c.submit(new Callable<BatchGeocodeResult>() { // from class: com.esri.core.tasks.geocode.Locator.7
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            public BatchGeocodeResult call() {
                BatchGeocodeResult batchGeocodeResult = null;
                try {
                    batchGeocodeResult = Locator.this.batchGeocode(list, spatialReference);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return batchGeocodeResult;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(batchGeocodeResult);
                }
                return batchGeocodeResult;
            }
        });
    }

    public Future<List<LocatorGeocodeResult>> find(final LocatorSuggestionResult locatorSuggestionResult, final int i, final List<String> list, final SpatialReference spatialReference, final CallbackListener<List<LocatorGeocodeResult>> callbackListener) {
        return e.c.submit(new Callable<List<LocatorGeocodeResult>>() { // from class: com.esri.core.tasks.geocode.Locator.8
            @Override // java.util.concurrent.Callable
            public List<LocatorGeocodeResult> call() {
                List<LocatorGeocodeResult> list2 = null;
                try {
                    list2 = Locator.this.find(locatorSuggestionResult, i, list, spatialReference);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                        callbackListener.onCallback(list2);
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return list2;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(list2);
                }
                return list2;
            }
        });
    }

    public Future<List<LocatorSuggestionResult>> suggest(final LocatorSuggestionParameters locatorSuggestionParameters, final CallbackListener<List<LocatorSuggestionResult>> callbackListener) {
        return e.c.submit(new Callable<List<LocatorSuggestionResult>>() { // from class: com.esri.core.tasks.geocode.Locator.9
            @Override // java.util.concurrent.Callable
            public List<LocatorSuggestionResult> call() {
                List<LocatorSuggestionResult> list = null;
                try {
                    list = Locator.this.suggest(locatorSuggestionParameters);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                        callbackListener.onCallback(list);
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return list;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(list);
                }
                return list;
            }
        });
    }

    public static Future<List<LocatorGeocodeResult>> findLocation(final String str, Locator locator, final CallbackListener<List<LocatorGeocodeResult>> callbackListener) {
        return e.b.submit(new Callable<List<LocatorGeocodeResult>>() { // from class: com.esri.core.tasks.geocode.Locator.10
            @Override // java.util.concurrent.Callable
            public List<LocatorGeocodeResult> call() {
                Locator locator2 = Locator.this;
                if (locator2 == null) {
                    locator2 = Locator.createOnlineLocator();
                }
                List<LocatorGeocodeResult> list = null;
                try {
                    LocatorFindParameters locatorFindParameters = new LocatorFindParameters(str);
                    locatorFindParameters.setOutSR(SpatialReference.create(SpatialReference.WKID_WGS84));
                    list = locator2.find(locatorFindParameters);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return list;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(list);
                }
                return list;
            }
        });
    }

    public static Future<LocatorReverseGeocodeResult> findAddress(final double d, final double d2, Locator locator, final CallbackListener<LocatorReverseGeocodeResult> callbackListener) {
        return e.b.submit(new Callable<LocatorReverseGeocodeResult>() { // from class: com.esri.core.tasks.geocode.Locator.11
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            public LocatorReverseGeocodeResult call() {
                Locator locator2 = Locator.this;
                if (locator2 == null) {
                    locator2 = Locator.createOnlineLocator();
                }
                Locator locator3 = locator2;
                LocatorReverseGeocodeResult locatorReverseGeocodeResult = null;
                try {
                    SpatialReference create = SpatialReference.create(SpatialReference.WKID_WGS84);
                    locatorReverseGeocodeResult = locator3.reverseGeocode(new Point(d2, d), 100.0d, create, create);
                } catch (Exception e) {
                    CallbackListener callbackListener2 = callbackListener;
                    if (callbackListener2 != null) {
                        callbackListener2.onError(e);
                    }
                }
                if (Thread.currentThread().isInterrupted()) {
                    return locatorReverseGeocodeResult;
                }
                CallbackListener callbackListener3 = callbackListener;
                if (callbackListener3 != null) {
                    callbackListener3.onCallback(locatorReverseGeocodeResult);
                }
                return locatorReverseGeocodeResult;
            }
        });
    }
}
